//
//  NewFontSizeView.m
//  LSYReader
//
//  Created by 王欣 on 2017/12/23.
//  Copyright © 2017年 okwei. All rights reserved.
//

#import "CBCFontSizeView.h"
#import "CommonFuctions.h"
#if __has_include(<Masonry/Masonry.h>)
#import <Masonry/Masonry.h>
#else
#import "Masonry.h"
#endif
@interface CBCFontSizeView()
@property(nonatomic,strong)UIButton * fontBtn;

@end
CGFloat height = 40;
@implementation CBCFontSizeView
-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        [self setupUI];
    }return self;
}
//
-(void)setupUI{
    [self addSubview:self.fontBtn];
    [self addSubview:self.fontAddBtn];
    [self addSubview:self.fontReduceBtn];
    [self.fontBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
        make.size.mas_equalTo(CGSizeMake(height, height));
        make.left.equalTo(self).offset(40);
    }];
    [self.fontAddBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.fontBtn);
        make.size.mas_equalTo(CGSizeMake(height*2.5, height));
        make.left.equalTo(self.fontBtn.mas_right).offset(40);
    }];
    [self.fontReduceBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.equalTo(self.fontAddBtn);
        make.centerY.equalTo(self.fontAddBtn);
        make.left.equalTo(self.fontAddBtn.mas_right);
    }];
    
}
-(void)btnClick:(UIButton*)btn{

    if (self.delegate&&[self.delegate respondsToSelector:@selector(fontChangeBtnClickIsLarge:)]) {
        if (btn==self.fontAddBtn) {
    
            [self.delegate fontChangeBtnClickIsLarge:YES];
        }else{
            [self.delegate fontChangeBtnClickIsLarge:NO];
        }
    }
}
-(UIButton *)fontBtn{
    if (!_fontBtn) {
        _fontBtn = [[UIButton alloc]init];
        [_fontBtn setTitle:@"字号" forState:(UIControlStateNormal)];
    }return _fontBtn;
}
-(UIButton *)fontAddBtn{
    if (!_fontAddBtn) {
        _fontAddBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
        [_fontAddBtn setImage:[CommonFuctions cbcReaderImage:@"fontLarge"] forState:(UIControlStateNormal)];
        [_fontAddBtn setImage:[CommonFuctions cbcReaderImage:@"fontLargeSel"] forState:(UIControlStateHighlighted)];
        [_fontAddBtn addTarget:self action:@selector(btnClick:) forControlEvents:(UIControlEventTouchUpInside)];
        [_fontAddBtn setImage:[CommonFuctions cbcReaderImage:@"fontLargeEnabled"] forState:(UIControlStateDisabled)];
  
  
    }return _fontAddBtn;
}
-(UIButton *)fontReduceBtn{
    if (!_fontReduceBtn) {
        _fontReduceBtn = [[UIButton alloc]init];

        [_fontReduceBtn setImage:[CommonFuctions cbcReaderImage:@"fontSmall"] forState:(UIControlStateNormal)];
        [_fontReduceBtn setImage:[CommonFuctions cbcReaderImage:@"fontSmallSel"] forState:(UIControlStateHighlighted)];
        [_fontReduceBtn addTarget:self action:@selector(btnClick:) forControlEvents:(UIControlEventTouchUpInside)];
        [_fontReduceBtn setImage:[CommonFuctions cbcReaderImage:@"fontSmallEnabled"] forState:(UIControlStateDisabled)];
    }return _fontReduceBtn;
}

@end
